package cn.outsourcing.supermarket.controller;

import cn.outsourcing.supermarket.common.CommonPage;
import cn.outsourcing.supermarket.common.Result;
import cn.outsourcing.supermarket.common.utils.ResultUtils;
import cn.outsourcing.supermarket.service.HiolabsFootprintService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 前端控制器
 *
 * @author gzkemays
 * @since 2021-10-23
 */
@RestController
@RequestMapping("/footprint")
public class HiolabsFootprintController {
  @Resource private HiolabsFootprintService footprintService;

  @GetMapping("/list")
  public Result getFootPrintGoodsList(CommonPage page) {
    return ResultUtils.simpleResult(footprintService.getFootPrintVo(page));
  }

  @PostMapping("/delete")
  public Result deleteFootPrint(@RequestBody Map<String, Integer> map) {
    boolean delete = footprintService.deleteFootprint(map.get("footprintId"));
    if (delete) {
      return ResultUtils.simpleResult("删除成功");
    }
    return ResultUtils.simpleResult("删除失败");
  }
}
